#pragma once

#include <iup.h>

#include <glm/glm.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

class DataSource
{
public:

    /**
     * Construtor
     */
    DataSource(Ihandle* parent);

    /**
     * Destrutor
     */
	~DataSource();;

    void getSensorFused(float* az, float* pitch, float* roll);
	void getTranslation(float* x, float* y, float* z);
	void getModelView(float* mv);
	void getCameraFrame(cv::Mat& frame);
	void getDataFrame(int markerPos,cv::Mat** dframe,cv::Mat** dframe_mask, int* marker_width ,int* marker_height);
	const std::vector<cv::Mat>& getMarkers();
	bool arDataChanged();
	
	static DataSource* init(Ihandle* parent, const char * device = NULL);



//internal - precisa ser publico por causa do iup
	void update();
	void updateSliders();
	void selectNewARData();

private:

	void createUI(Ihandle* parent);
	Ihandle* initSliders( void );
	Ihandle* initImageOpener( void );

	bool initCamera(const char* device);

   Ihandle* _dialog;
   cv::VideoCapture _capture;
   Ihandle *_azimuthVal, *_pitchVal, *_rollVal,*_azimuthTxt,*_pitchTxt,*_rollTxt,* _arDataTxt;   
   float _azimuth,_pitch,_roll;
   bool _isStopped;
   cv::Mat _lastFrame;
   std::vector<cv::Mat> _markers;
   std::vector<cv::Mat> _imagesToOverlap;
   std::vector<cv::Mat> _imagesToOverlapAlpha;
   bool _arDataChanged;
};

